﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Demo03"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModels="using:Demo03.ViewModels"
    x:Class="Demo03.MainPage"
    mc:Ignorable="d">
    <Page.DataContext>
        <ViewModels:MainPageViewModel/>
    </Page.DataContext>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid Height="400" Width="400">
            <ItemsControl ItemsSource="{Binding HoursTicks}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="20" RenderTransformOrigin="0.5,0.5">
                            <Grid.RenderTransform>
                                <CompositeTransform Rotation="{Binding Angle}"/>
                            </Grid.RenderTransform>
                            <TextBlock Text="{Binding Text}" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" >
                                <TextBlock.RenderTransform>
                                    <CompositeTransform Rotation="{Binding ReverseAngle, Mode=OneWay}"/>
                                </TextBlock.RenderTransform>
                            </TextBlock>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <ItemsControl ItemsSource="{Binding SecondTicks}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid RenderTransformOrigin="0.5,0.5">
                            <Grid.RenderTransform>
                                <CompositeTransform Rotation="{Binding Angle}"/>
                            </Grid.RenderTransform>
                            <Line Stroke="White" StrokeThickness="4"
                                  VerticalAlignment="Top"
                                  HorizontalAlignment="Center"
                                  X1="2" X2="2" Y1="10" Y2="0" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <Line Stroke="Red" StrokeThickness="10"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  X1="5" X2="5" Y1="0" Y2="-175" RenderTransformOrigin="0.5,0.5" >
                <Line.RenderTransform>
                    <CompositeTransform Rotation="{Binding SecondAngle}"/>
                </Line.RenderTransform>
            </Line>

            <Line Stroke="White" StrokeThickness="10"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  X1="5" X2="5" Y1="0" Y2="-175" RenderTransformOrigin="0.5,0.5" >
                <Line.RenderTransform>
                    <CompositeTransform Rotation="{Binding MinuteAngle}"/>
                </Line.RenderTransform>
            </Line>

            <Line Stroke="Silver" StrokeThickness="10"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  X1="5" X2="5" Y1="0" Y2="-100" RenderTransformOrigin="0.5,0.5" >
                <Line.RenderTransform>
                    <CompositeTransform Rotation="{Binding HourAngle}"/>
                </Line.RenderTransform>
            </Line>

        </Grid>
    </Grid>
</Page>
